<!--#include virtual="/Common/Config.asp" -->
<!--#include virtual="/Common/conn.asp" -->
<!--#include virtual="/2010admin/Check_IsLogin.asp" -->
<!--#include virtual="/Common/Function.asp" -->
<!--#include file="ad_system_inc.asp" -->
<%
If Request.ServerVariables ("Request_Method")="POST" Then
	ad_id=reform("ad_id")
Else
	ad_id=requery("ad_id")
End If
Call Check_IsNumeric_Msg(ad_id,"ID只能是数字")

If Request.ServerVariables ("Request_Method")="POST" Then
	'禁止从网站外部提交数据
	Call Deny_OutSiteSubit()
	If requery("action")="add" Then
		detail_Add()
	End If
	If requery("action")="edit" Then
		detail_edit()
	End If

	If requery("action")="editsave" Then
		detail_editsave()
	End If
	
	If requery("action")="del" Then
		detail_Del()
	End If
End If



%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="/2010admin/css/default.css" type="text/css" rel="stylesheet">
<script language="javascript" src="/2010admin/js/validator.js"></script>
<script language="javascript"> 
function checkall(field)
{
	var sall = document.getElementById("list2").checked;
	if (field.length)
	{
		slength = field.length;
		for (var i = 0; i < slength; i++) 
		{ 
			field[i].checked = sall;
		}
	}
	else { 
		field.checked = sall; 
	}
}
function checkform()
{
 var groups = document.getElementsByName("ID");
 var hasChecked = 0;
 for(var i=0; i<groups.length;i++)
	if(groups[i].checked) hasChecked++;
	
if(hasChecked==0)
{
	alert("至少选择一条要修改的记录!");
	return false;
}
else document.getElementById("list_form").submit();
}


function delcheck(){
	var groups = document.getElementsByName("ID");
	var hasChecked = 0;
	for(var i=0; i<groups.length;i++)
	if(groups[i].checked) hasChecked++;

	if(hasChecked==0)
	{
	alert("至少选择一条要删除的记录!");
	return false;
	}

	if (confirm('是否真的要删除这条记录？')) {
		document.getElementById("list_form").action="ad_system_query.asp?action=del";
		document.getElementById("list_form").submit();
	}
	else return false;
}

function gen_js(){
	 var groups = document.getElementsByName("ID");
	 var hasChecked = 0;
	 for(var i=0; i<groups.length;i++)
	if(groups[i].checked) hasChecked++;
	
	if(hasChecked==0)
	{
		alert("至少选择一条要生成的记录!");
		return false;
	}

	if (confirm('是否真的要生成这条记录？')) {
		document.getElementById("list_form").action="ad_system_query.asp?action=del";

		document.getElementById("list_form").submit();
	}
	else return false;
}
//-->
</script>

</head>
<body>

<table border="0" width="100%" cellSpacing="0" cellPadding="0">
  <tr>
    <td width="100%" height="5"></td>
  </tr>
  <tr>
    <td width="100%" align="center">
      <table border="0" width="98%" cellSpacing="0" cellPadding="0">
        <tr>
          <td width="*" align="left" valign="top">
            <table border="0" width="100%" cellSpacing="0" cellPadding="0" class="lrbtline">
              <tr>
                <td width="100%" height="25" class="tbtop">管理导航</td>
              </tr>
              <tr>
                <td width="100%" align="left">
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                  <table border="0" width="98%" cellSpacing="0" cellPadding="0">
                    <tr>
                      <td width="100%" height="20">&nbsp;<img src="/2010admin/images/sico.gif" border="0"><span id="userlist"><a href="ad_system_query.asp">广告管理</a></span>&nbsp;<img src="/2010admin/images/sico.gif" border="0"><span id="userlist"><a href="ad_system_detail_query.asp?ad_id=<%=ad_id%>">广告明细管理</a></span></td>
                    </tr>
                    <tr>
                      <td width="100%" height="5"></td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            <table border="0" width="100%" cellSpacing="0" cellPadding="0">
              <tr>
                <td width="100%" height="5"></td>
              </tr>
            </table>

			<%
			Select Case requery("action")
				Case "e" Call Edit_Form()
				Case Else Call Main()
			End Select		
			%>

          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td width="100%" height="5"></td>
  </tr>
</table>
</body>
</html>
<%
Call conn_close()

Sub Main()
sql="SELECT ID,ad_d_title,ad_d_image,ad_d_url,ad_d_order FROM ad_system_detail WHERE ad_id=" &ad_id
Set rs=conn.execute(sql)
If Not rs.Eof Then
%>
		  <table width="98%" border="0" cellPadding="0" cellSpacing="0" class="tablesh">
		  <form action="?action=edit" method="post" name="list_form" id="list_form">
			<tr>
			  <td width="95" height="25"><div align="center">选择</div></td>
			  <td>文字标题</td>
			  <td>图片位置</td>
			  <td>链接URL</td>
			  <td>位置顺序</td>
			  <td>操作</td>
			</tr>
			<%
			Do While Not rs.Eof

				ID			= rs(0) 
				ad_d_title	= rs(1) 
				ad_d_image	= rs(2) 
				ad_d_url	= rs(3) 
				ad_d_order	= rs(4)

			%>
			<tr>
			  <td width="95" height="25"><div align="center">
				<input name="ID" type="checkbox" id="ID" value="<%=ad_id%>" >
			  </div></td>
			  <td><%=ad_d_title%></td>
			  <td width="187"><%=ad_d_image%>&nbsp;</td>
			  <td width="187"><%=ad_d_url%>&nbsp;</td>
			  <td width="187"><%=ad_d_order%>&nbsp;</td>
			  <td width="83"><a href="?action=e&ID=<%=id%>&ad_id=<%=ad_id%>">修改</a></td>
			</tr>
			<%
			rs.movenext
			Loop
			%>
			<tr>
			  <td  width="95"><div align="center">
				<input type=checkbox name="list2" onClick="checkall(this.form.ID);"  >

				</div></td>
			  <td>&nbsp;
			  <input type="button" name="button2" value="删除" class="button" onClick="return delcheck();">
			  
			  </td>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			  <td>&nbsp;</td>
			</tr>
		  </form>
		  </table>

	 <%
	 End If 
	 rs.close
	 %>
	<table width="98%" border="0" cellPadding="0" cellSpacing="0" class="tablesh">
	  <form action="?action=add" method="post" name="form" id="form" onSubmit="return Validator.Validate(this, 2)">
		<tr>
		  <td colspan=2 height="25">增加明细内容</td>
		</tr>
		<tr>
		  <td width="95" height="25">文字标题</td>
		  <td >
		  <input name="ad_d_title" type="text" id="ad_d_title" size="20" maxlength="100" dtype="Limit" min="2" max="100" dmsg="文字标题必须在2-100个字符之间" ></td>
		</tr>
		<tr>
		  <td width="95" height="25">图片</td>
		  <td >
			<input type="text" name="ad_d_image" size="60" ><iframe id=d_file frameborder=0 src="/2010admin/common/File_Upload.asp?change_field=ad_d_image" width="300" height="40" scrolling=no></iframe>   
			</td>
		</tr>
		<tr>
		  <td width="95" height="25">链接URL</td>
		  <td >
		  <input name="ad_d_url" type="text" id="ad_d_url" size="20" maxlength="100" dtype="Limit" min="0" max="200" dmsg="链接URL必须小于200个字符" ></td>
		</tr>
		<tr>
		  <td width="95" height="25">位置顺序</td>
		  <td >
		  <input name="ad_d_order" type="text" id="ad_d_order" size="20" maxlength="100" dtype="Integer" dmsg="位置顺序必须是数字" ></td>
		</tr>
		<tr>
		  <td height="25" colspan="2">
		  <input type="submit" name="submit" value="增加" class="button">
		  <input name="ad_id" type="hidden" id="ad_id" value="<%=ad_id%>" />
		  &nbsp;</td>
		</tr>
	  </form>
	</table>
<%
End Sub

Sub Edit_Form()
Ad_ID = requery("Ad_ID")
ID	 = requery("ID")
Call Check_IsNumeric_Msg(ID,"ID") 
Call Check_IsNumeric_Msg(Ad_ID,"ID") 

Sql = "SELECT ID,ad_d_title,ad_d_image,ad_d_url,ad_d_order FROM ad_system_detail WHERE ID="&ID
Array_List = GetRsRows(Sql)
If IsArray(Array_List)=False Then 
	AlertBox "记录不存在!","javascript:history.go(-1)"
Else
	ID			= Array_List(0,0)
	ad_d_title	= Array_List(1,0)
	ad_d_image	= Array_List(2,0)
	ad_d_url	= Array_List(3,0)
	ad_d_order	= Array_List(4,0)
End If
%>
  <table width="100%" border="0" cellPadding="0" cellSpacing="0" class="tablesh">
	<form action="?action=editsave" method="post" name="form" id="form" onSubmit="return Validator.Validate(this, 2)">
	<tr>
	  <td width="95" height="25">文字标题</td>
	  <td >
	  <input name="ad_d_title" value="<%=ad_d_title%>" type="text" id="ad_d_title" size="20" maxlength="100" dtype="Limit" min="2" max="100" dmsg="文字标题必须在2-100个字符之间" ></td>
	</tr>
	<tr>
	  <td width="95" height="25">图片</td>
	  <td >
		<input type="text" name="ad_d_image"   value="<%=ad_d_image%>" size="60" ><iframe id=d_file frameborder=0 src="File_Upload.asp?change_field=ad_d_image" width="300" height="40" scrolling=no></iframe>   
		</td>
	</tr>
	<tr>
	  <td width="95" height="25">链接URL</td>
	  <td >
	  <input name="ad_d_url"  value="<%=ad_d_url%>" type="text" id="ad_d_url" size="20" maxlength="100" dtype="Limit" min="0" max="200" dmsg="链接URL必须小于200个字符" ></td>
	</tr>
	<tr>
	  <td width="95" height="25">位置顺序</td>
	  <td >
	  <input name="ad_d_order" value="<%=ad_d_order%>" type="text" id="ad_d_order" size="20" maxlength="100" dtype="Integer" dmsg="位置顺序必须是数字" ></td>
 					                  
 					                  
	<tr>
	  <td height="25" colspan="2">
	  <input type="submit" name="submit" value="修改" class="button">
	  &nbsp;<input type="button" name="button2" value="返回" class="button" onclick="history.back();">
	  <input name="ad_id" type="hidden" id="ad_id" value="<%=ad_id%>" />
	  <input name="id" type="hidden" id="id" value="<%=id%>" />
	  </td>
	</tr>
  </form>
  </table>

<% End Sub %>